package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.scientific.domain.Scientific;
import com.ruoyi.scientific.service.IScientificService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 科学可视化Controller
 * 
 * @author 王强
 * @date 2024-01-20
 */
@RestController
@RequestMapping("/frist/scientific")
public class ScientificController extends BaseController
{
    @Autowired
    private IScientificService scientificService;

    /**
     * 查询科学可视化列表
     */
    @PreAuthorize("@ss.hasPermi('frist:scientific:list')")
    @GetMapping("/list")
    public TableDataInfo list(Scientific scientific)
    {
        startPage();
        List<Scientific> list = scientificService.selectList(scientific);
        return getDataTable(list);
    }

    /**
     * 导出科学可视化列表
     */
    @PreAuthorize("@ss.hasPermi('frist:scientific:export')")
    @Log(title = "科学可视化", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Scientific scientific)
    {
        List<Scientific> list = scientificService.selectList(scientific);
        ExcelUtil<Scientific> util = new ExcelUtil<Scientific>(Scientific.class);
        util.exportExcel(response, list, "科学可视化数据");
    }

    /**
     * 获取科学可视化详细信息
     */
    @PreAuthorize("@ss.hasPermi('frist:scientific:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(scientificService.selectById(id));
    }

    /**
     * 新增科学可视化
     */
    @PreAuthorize("@ss.hasPermi('frist:scientific:add')")
    @Log(title = "科学可视化", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Scientific scientific)
    {
        return toAjax(scientificService.insert(scientific));
    }

    /**
     * 修改科学可视化
     */
    @PreAuthorize("@ss.hasPermi('frist:scientific:edit')")
    @Log(title = "科学可视化", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Scientific scientific)
    {
        return toAjax(scientificService.update(scientific));
    }

    /**
     * 删除科学可视化
     */
    @PreAuthorize("@ss.hasPermi('frist:scientific:remove')")
    @Log(title = "科学可视化", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(scientificService.deleteByIds(ids));
    }
}
